'use strict';
module.exports = {
	/**
	 * 分类列表
	 * @url client/pages/pub/tv_categoryList 前端调用的url参数地址
	 * data 请求参数
	 * @param {String} params1  参数1
	 */
	main: async (event) => {
		let { data = {}, userInfo, util, filterResponse, originalParam } = event;
		let { customUtil, uniID, config, pubFun, vk, db, _ } = util;
		let { uid, appid ,category,type} = data;
		let res = { code: 0, msg: "" };
		// 业务逻辑开始-----------------------------------------------------------
		// 先判断是否为全部展示
		if (category == "全部"){
			let tvRank = await db.collection('a_tv').where({
				status: true,
				appid: _.or(_.eq([]), _.in([appid])), //数组为空或包含了appid,既满足条件
			}).orderBy(type, 'desc').limit(100).get()
			res.tvList = tvRank.data
		}else {
			//====根据分类和筛选加载视频====
			let tvRank = await db.collection('a_tv').where({
				status: true,
				appid: _.or(_.eq([]), _.in([appid])), //数组为空或包含了appid,既满足条件
				tv_class: category
			}).orderBy(type, 'desc').limit(100).get()
			res.tvList = tvRank.data
		}
		
		//====加载排行页视频====

		// 业务逻辑结束-----------------------------------------------------------
		return res;
	}
}
